package com.woniuxy.springboottest.handler;

import com.woniuxy.springboottest.bean.UserBean;
import com.woniuxy.springboottest.result.ResponseResult;
import com.woniuxy.springboottest.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @author linke
 * @version 1.0
 * @className: UserHandler
 * @description: USER操作控制器
 * @date 2021/11/16 16:57
 */
@RestController//不进行页面跳转
@RequestMapping("/user")
public class UserHandler {


    @RequestMapping("/login")
    public String login(){
        return "success";
    }

    @RequestMapping("/data")
    public ResponseResult<UserBean> data(){
        return new ResponseResult<UserBean>(
                "200",
                "success",
                new UserBean(1001,"张三","1111",new Date()));//{"code":"200","msg":"success","data":{"uid":1001,"uname":"张三","pwd":"1111","birthday":"2021-11-16 11:52:48"}}
    }

    @Autowired
    private IUserService userService;

    @RequestMapping("/all")
    public List<UserBean> all(){

        return userService.findAll();//[{"uid":1,"uname":"2","pwd":"2","birthday":null}]
    }
}